package cn.alm.mybatis01helloworld.controller;

import cn.alm.mybatis01helloworld.common.CR;
import cn.alm.mybatis01helloworld.entity.Emp;
import cn.alm.mybatis01helloworld.service.EmpService;
import cn.alm.mybatis01helloworld.vo.PageVo;
import com.github.pagehelper.PageInfo;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("emp")
@CrossOrigin
public class EmpController {

    @Resource
    private EmpService empService;

    @PostMapping("listByPage")
    public CR listByPage(@RequestBody PageVo pageVo) {
        PageInfo<Emp> empPageInfo = empService.getEmpList(pageVo.getPage(), pageVo.getSize());
        CR cr = new CR();
        cr.setData(empPageInfo);
        cr.setCode(200);
        cr.setMsg("查询成功");
        return cr;
    }
}
